package com.xo.mall.controller.pms;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.xo.common.Result.CommonPage;
import com.xo.common.Result.ResultResponse;
import com.xo.common.pojo.dto.req.GetPageProductListReqDto;
import com.xo.common.pojo.dto.req.PmsProductCreateReqDto;
import com.xo.common.pojo.vo.PageProductListVo;
import com.xo.common.pojo.vo.ProductInfoByProductIdVo;
import com.xo.mall.server.PmsProductService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/mall/pms")
@Tag(name = "商品管理")
public class PmsProductController {

    @Resource
    private PmsProductService pmsProductService;

    @PostMapping("/createProduct")
    @ApiOperationSupport(author = "dayu", order = 1)
    @Operation(summary = "创建商品", description = "创建商品")
    public ResultResponse<String> createProduct(@RequestBody PmsProductCreateReqDto pmsProductCreateReqDto){
        return pmsProductService.createProduct(pmsProductCreateReqDto);
    }

    @GetMapping("/getProductInfoByProductId")
    @ApiOperationSupport(author = "dayu", order = 2)
    @Operation(summary = "根据productId查询商品信息", description = "根据productId查询商品信息")
    public ResultResponse<ProductInfoByProductIdVo> getProductInfoByProductId(@RequestParam Integer productId){
        return pmsProductService.getProductInfoByProductId(productId);
    }

    @PostMapping("/getPageProductList")
    @ApiOperationSupport(author = "dayu", order = 2)
    @Operation(summary = "分页获取商品列表", description = "分页获取商品列表")
    public ResultResponse<CommonPage<PageProductListVo>> getPageProductList(@RequestBody GetPageProductListReqDto getPageProductListReqDto) {
        return pmsProductService.getPageProductList(getPageProductListReqDto);
    }

}
